<template>
	<view class="aftersales-wp">
		<view class="sales-nav">
			<view class="title">商家已经通过售后申请</view>
			<view class="cont">
				<view>退款退货申请流程：</view>
				<view>1、发起退款退货申请</view>
				<view>2、退货需将退货商品邮寄至商家指定地址，并在系统内输入快递单号</view>
				<view>3、商家后货后确认无误</view>
				<view>4、退款到您的账户</view>
			</view>
			<view class="address">
				退货地址：<text>{{info.refund.address_info}}</text>
			</view>
			<view class="address">
				退货状态：<text>{{info.refund.status=='3'?'请您填写快递单号':'等待商家确认'}}</text>
			</view>
		</view>
		<view class="sales-nav">
			<view class="title">协商详情</view>
			<view class="cont">
				<view>处理方式：{{way}}</view>
				<view>退款原因：{{info.refund.reason}}</view>
				<view>退款说明：{{info.refund.content==''?'暂未说明':info.refund.content}}</view>
				<view>退款金额：{{info.showprice}}元</view>
				<view>申请时间：{{info.refund.createtime}}</view>
				<view v-if="info.refund.status=='4'">快递公司名称：{{info.refund.expresscom}}</view>
				<view v-if="info.refund.status=='4'">快递号：{{info.refund.expresssn}}</view>
			</view>
		</view>
		<button type="default" v-if="info.refund.status=='3'" class="btn" style="background-color: #8405dc;color: #fff;" @tap="goo('CourierNumber',id,info.refund.id)">填写快递单号</button>
		<button type="default" class="btn" style="background-color: #ddd;color: #666;" @tap="canceltap()">取消售后申请</button>
	</view>
</template>

<script>
	export default {
		name: 'AfterSales',
		data() {
			return {
				way: '',
				info: {refund:{},},
				courier: '',
				id: ''
			}
		},
		onLoad(options) {
			var _this = this;
			_this.id = options.id;
			this.$axios('op/refund', 'POST', 'order', {
				orderid: _this.id
			}).then(res => {
				if (res.data.code = 200) {
					_this.info = res.data.data;
					if (_this.info.order.status == '3') {
						_this.way = '退货退款';
					}
				}
			})
		},
		methods: {
			canceltap() {
				var that = this;
				that.$axios('op/submitRefund', "POST", 'order', {
					orderid: that.id,
					cancel: 1
				}).then(res => {
					if (res.data.code == 200) {
						uni.showModal({
							title: '取消成功！',
							showCancel: false,
							success() {
								that.$navBack();
							}
						})
					}
				})
			},
			go(url, id) {
				uni.navigateTo({
					url: url + "?id=" + id
				})
			},
			goo(url, id, id2) {
				uni.navigateTo({
					url: url + "?id=" + id + '&id2=' + id2
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f2f2f2;
	}

	.aftersales-wp {
		overflow: hidden;
		font-size: 28upx;
		color: #666;
	}

	.sales-nav {
		margin-top: 30upx;
		background-color: #fff;
		padding: 0 20upx 20upx;

		.title {
			color: #000;
			line-height: 88upx;
			border-bottom: 1px #C0C4CC solid;
		}

		.cont {
			color: #666;
			line-height: 50upx;
		}

		.address {
			padding-top: 40upx;

			text {
				line-height: 50upx;
				color: $base-color;
				overflow: hidden;
			}
		}
	}

	.btn {
		width: 96%;
		margin-top: 30upx;
	}
</style>
